namespace Smarts.Internal.Test.Core
{
    using NUnit.Framework;
    using Smarts.Core;

    [TestFixture]
    public class VersionNumberTests
    {
        [Test]
        public void CanParseSingleNumberVersion()
        {
            var version = VersionNumber.Parse("5");
            Assert.That(version.Major, Is.EqualTo(5));
            Assert.That(version.Minor, Is.EqualTo(0));
            Assert.That(version.Revision, Is.EqualTo(0));
            Assert.That(version.Build, Is.EqualTo(0));
        }

        [Test]
        public void CanParseDoubleNumberVersion()
        {
            var version = VersionNumber.Parse("2.5");
            Assert.That(version.Major, Is.EqualTo(2));
            Assert.That(version.Minor, Is.EqualTo(5));
            Assert.That(version.Revision, Is.EqualTo(0));
            Assert.That(version.Build, Is.EqualTo(0));
        }

        [Test]
        public void CanParseTripleNumberVersion()
        {
            var version = VersionNumber.Parse("3.2.1");
            Assert.That(version.Major, Is.EqualTo(3));
            Assert.That(version.Minor, Is.EqualTo(2));
            Assert.That(version.Revision, Is.EqualTo(1));
            Assert.That(version.Build, Is.EqualTo(0));
        }

        [Test]
        public void CanParseQuadNumberVersion()
        {
            var version = VersionNumber.Parse("6.9.8.3");
            Assert.That(version.Major, Is.EqualTo(6));
            Assert.That(version.Minor, Is.EqualTo(9));
            Assert.That(version.Revision, Is.EqualTo(8));
            Assert.That(version.Build, Is.EqualTo(3));
        }

        [Test]
        public void CanTryParseSingle()
        {
            VersionNumber v;
            Assert.IsTrue(VersionNumber.TryParse("1", out v));
            Assert.IsTrue(VersionNumber.TryParse("13", out v));
            Assert.IsFalse(VersionNumber.TryParse("03", out v));
        }
    }
}